﻿Imports System.Reflection

''' <summary>
''' 削除ダーティオブジェクト
''' </summary>
''' <remarks>
''' 削除されたオブジェクトを示すクラス
''' </remarks>
Public Class DeleteDirtyObject
    Inherits DirtyObject

    ''' <summary>
    ''' コンストラクタ
    ''' </summary>
    ''' <param name="arch"></param>
    ''' <remarks></remarks>
    Public Sub New(arch As ItemEntityArchive)
        If arch Is Nothing Then Throw New ArgumentNullException("arch")

        Me.Archive = arch

        Me.Key = arch.Key
        Me.InstanceType = Me.Archive.ClassType
    End Sub

    Private _archive As ItemEntityArchive
    ''' <summary>
    ''' アイテムアーカイブ
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Archive As ItemEntityArchive
        Get
            Return _archive
        End Get
        Private Set(ByVal value As ItemEntityArchive)
            _archive = value
        End Set
    End Property

    ''' <summary>
    ''' ダーティタイプ
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides ReadOnly Property DirtyType As DirtyTypes
        Get
            Return DirtyTypes.Delete
        End Get
    End Property

    ''' <summary>
    ''' ダーティプロパティ
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overrides ReadOnly Property DirtyProperties As IEnumerable(Of LiteralProperty)
        Get
            '削除の場合ありません
            Return Enumerable.Empty(Of LiteralProperty)()
        End Get
    End Property

    ''' <summary>
    ''' リテラル名、アーカイブ値の辞書
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public ReadOnly Property KeyDictionay As Dictionary(Of String, LiteralPropertyArchive)
        Get
            Dim dic As New Dictionary(Of String, LiteralPropertyArchive)

            For Each item In Me.KeyProperties
                Dim name = item.LiteralName
                Dim val = Me.Archive.ItemArchives(name)
                dic.Add(name, val)
            Next

            Return dic
        End Get
    End Property
End Class
